package com.hmall.user.controller;


import com.hmall.user.pojo.Adderss;
import com.hmall.user.pojo.User;
import com.hmall.user.service.UserService;
import com.hmall.user.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@RequestMapping("address")
public class UserController {
    @Autowired
    public UserService userService;

    //获取user

    @GetMapping("/address/uid")
    public List<Adderss> getUserById() {
        return userService.getUserById();
    }

    //根据id查询用户
    @GetMapping("/user/{id}")
    User findUserById(@PathVariable("id") Long id) {

        return userService.findUser(id);
    }

    @GetMapping("/item/users/{id}/{bs}")
    void updateUser(@PathVariable("id") Long id, @PathVariable("bs") Long bs){
        userService.updateUser(id,bs);
    }

    @GetMapping("/address/{addressId}")
    public Adderss getAddressById(@PathVariable("addressId") Long id) {
        return userService.getAddressById(id);
    }
}
